package bb.lanxing.calc.calculator;

import bb.lanxing.calc.data.GpsPoint;
import bb.lanxing.calc.data.SourcePoint;
//import org.osmdroid.util.constants.UtilConstants;
public class GpsLostCalc {

    private static final long GPS_WAIT_TIME = 20000;
    private GpsPoint lastGpsPoint;
    private long lastGpsTime = 0;

    public boolean isGpsLost(SourcePoint sourcePoint) {
        if (!sourcePoint.hasGps() || sourcePoint.isOldPoint() || sourcePoint.getGpsPoint().equals(this.lastGpsPoint)) {
            return System.currentTimeMillis() - this.lastGpsTime > GPS_WAIT_TIME;
        }
        this.lastGpsTime = System.currentTimeMillis();
        this.lastGpsPoint = sourcePoint.getGpsPoint();
        return false;
    }

    public void release() {
        this.lastGpsTime = 0L;
        this.lastGpsPoint = null;
    }
}
